<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>确认订单</title>
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no" />
    <link type="text/css" rel="stylesheet" href="__TMPL__Public/assets/css/orderstyle.css">
    <link type="text/css" rel="stylesheet" href="__TMPL__Public/assets/css/order.css">
    <script src="__TMPL__Public/assets/js/jquery-v1.10.2.min.js"></script>
    <script type="text/javascript" src="__TMPL__Public/assets/layer/layer.js"></script>
    <style>
        .ddInform001 ul li .span_015{
            width:40%;
        }
        .ddInform001 ul li .span_016{
            width:10%;
        }
        .ddInform001 ul li .span_017{
            width:26%;
        }

        .ddInform001 ul li .span_018{
            width:15%;
            color:#ff8400;
        }

        .ddInform001 ul li .span_033{
            width:78%;
        }
        .ddInform001 ul li .span_034{
            width:18%;
            color:#ff8400;
        }

        .ddInform ul li .span_018 select{
            width:48%;
            background: #f8f8fa;
            border:1px solid #e1e1e1;
            border-radius: 5px;
            line-height: 2.4rem;
            text-indent: 2%;
        }
        .ddInform ul li .span_012{
            width:33%;
        }
        .ddInform ul li .span_018{
            width:63%;
            color:#666;
            text-align: left;
            position: relative;
        }
        .err_ticket{
            float:right;
            padding-top:1.1rem;
            padding-right:1.5rem;
            color:red;
            font-size:0.3rem;
        }
        .layui-layer-btn a{
            width:45%;
        }
    </style>
</head>
<body>
<div class="bgl01 bgl02">
    <form method="post" id="add-form">
        <input type="hidden" name="order_type" value="2">
        <input type="hidden" name="cart" value="true">
        <div class="ddBox">
            <div class="ddTitle clearFix">
                <div class="title002"><img src="__TMPL__Public/assets/img/icon032.png">配送信息</div>
            </div>
            <div class="ddInform">
                <ul>
                    <li>
                        <div style="float:left;width:50%;">
                            <span class="span_012" style="text-align: left;text-indent: 3em;">收货人：</span>
                            <span class="span_018">邓先生</span>
                        </div>
                        <div style="float:right;width:50%;">
                            <span class="span_012">联系电话：</span>
                            <span class="span_018">15011417119</span>
                        </div>
                        <div style="clear: both;"></div>
                    </li>
                    <li>
                        <span class="span_012" style="text-align: left;text-indent:3em;">地址：</span>
                        <span class="span_018">北京北京市朝阳区管庄朝通嘉园1号楼4单元451</span>
                    </li>
                </ul>
            </div>
        </div>
        <div class="ddBox">
            <div class="ddTitle clearFix">
                <div class="title002"><img src="__TMPL__Public/assets/img/icon033.png">商品信息</div>
            </div>
            <div class="ddInform001">
                <ul>
                    <foreach name="carts" item="vo" key="k">
                        <li>
                            <input type="hidden" name="goods[{$k}][goods_id]" value="{$vo.shop_id}"/>
                            <input type="hidden" name="goods[{$k}][goods_name]" value="{$vo.shop_title}"/>
                            <input type="hidden" name="goods[{$k}][goods_sn]" value="XF0000255"/>
                            <input type="hidden" name="goods[{$k}][goods_num]" value="{$vo.shop_num}"/>
                            <input type="hidden" name="goods[{$k}][goods_price]" value="{$vo.price}"/>
                            <input type="hidden" name="goods[{$k}][spec_key]" value="{$vo.size_id}"/>
                            <input type="hidden" name="goods[{$k}][spec_key_name]" value="{$vo.size_name}"/>
                            <span class="span_015">{$vo.shop_title}({$vo.size_name})</span>
                            <span class="span_016">{$vo.shop_num}{$vo.shop_pany}</span>
                            <span class="span_017">¥{$vo.price}/{$vo.shop_pany}</span>
                            <span class="span_018">¥{$vo['shop_num'] * $vo['price']}</span>
                            <php>
                                $total += $vo['shop_num'] * $vo['price'];
                            </php>
                        </li>
                    </foreach>
                </ul>
            </div>
        </div>
        <!--<div class="ddBox">
            <div class="ddTitle clearFix">
                <div class="title002" style="width:100%;"><img src="__TMPL__Public/assets/img/icon-sale-active.png">优惠券<sapn class="err_ticket"></span></div>
            </div>
            <div class="fyh pux" style="display:block;" onclick="ticket_click()">
                <input type="hidden" name="ticket_id" value=""/>
                <input type="hidden" name="ticket_type" value="1"/>
                <input type="hidden" name="total_price" value="89"/>
                <span class="span_018">请选择优惠券</span>
                <a href="javascript:void(0);" ></a>
            </div>
        </div>-->
        <div class="ddBox">
            <div class="ddTitle clearFix">
                <div class="title002"><img src="__TMPL__Public/assets/img/icon034.png">商品费用详情</div>
            </div>
            <div class="fyh">
                <span class="span_018">费用合计：</span>
                <span class="span_019">¥{$total}</span>
            </div>
        </div>

        <div class="ddBox">
            <div class="ddTitle clearFix">
                <div class="title002"><img src="__TMPL__Public/assets/img/icon035.png">物流方式</div>
            </div>
            <div class="wlMode">
                <ul>
                    <li>
                        <label for="radio01">普通物流<span>（邮费10元）</span></label>
                        <input type="radio" name="shipping_type" value="0" id="radio01"   class="input007" onclick="test(this)"/>
                       <!-- <div class="pux" id="Div1" >
                            <input type="hidden" name="address_id" value=""/>
                            <div><strong>选择地址</strong></div>
                            <p class="line2"> </p>
                            <a href="javascript:void(0)" onclick="address()"></a>
                        </div>-->
                    </li>
                </ul>
            </div>
        </div>
        <div class="qrBtn" id="subbtn"><a href="javascript:void(0)">提交并支付</a></div>
    </form>
</div>
<script>
    $(function(){
        $('#subbtn').click(function(){
//            var pay_code = "alipayMobile";
//            if(pay_code == 'alipayMobile'){
//                myalert('请关注微信：“云校服定制”');
//                return false;
//            }
            myconfirm("请您再次核查订单，提交后将无法取消和修改!",['确认提交','取消'],function(){
                submitFormFunc();
            });
        });
    });
    function submitFormFunc(){
        var realname = $('input[name="realname"]').val();
        var phone = $('input[name="phone"]').val();
        var faddress = $('input[name="faddress"]').val();
        var cname = $('input[name="cname"]').val();
        var csex = $('input[name="csex"]').val();
        var cbirth = $('input[name="cbirth"]').val();
        var cweight = $('input[name="cweight"]').val();
        var cheight = $('input[name="cheight"]').val();
        var cclass = $('select[name="cclass"]').val();
        var cgrade = $('select[name="cgrade"]').val();
        var cleader = $('input[name="cleader"]').val();

        var code = $('input[name="code"]').val();

        if(realname == ''){
            myalert('请输入家长姓名');
            return false;
        }

        if(phone == ''){
            myalert('请输入联系电话');
            return false;
        }

        if(faddress == ''){
            //myalert('请输入家庭地址');
            //return false;
        }

        if(cname == ''){
            myalert('请输入孩子姓名');
            return false;
        }

        if(csex == ''){
            myalert('请输入孩子性别');
            return false;
        }

        if(cbirth == ''){
            myalert('请输入孩子出生年月');
            return false;
        }

        if(cweight == ''){
            myalert('请输入孩子体重');
            return false;
        }

        if(cheight == ''){
            myalert('请输入孩子身高');
            return false;
        }

        if(cclass == ''){
            myalert('请选择孩子班级');
            return false;
        }

        if(cgrade == ''){
            myalert('请选择孩子年级');
            return false;
        }

        if(cleader == ''){
            myalert('请输入班主任姓名');
            return false;
        }

        //物流
        var shipping_type = $('input[name=shipping_type]:checked').val();
        var address_id = $('input[name="address_id"]').val();

        if(shipping_type == '' || shipping_type == undefined ){
            myalert('请选择物流方式');
            return false;
        }else if(shipping_type == 0 && address_id <= 0){
            myalert('请填选择货地址');
            return false;
        }else if(shipping_type == 2 ){
            if( code == ''){
                //myalert('请填校服定制码');
                //return false;
            }
            createorder();
            return false;
        }
        createorder();
    }
    function createorder(){
        layer.open({type: 2,time:60,shadeClose:false});
        $.post('/index.php/Mobile/Order/createOrder.html',$('#add-form').serialize(),function(data){
            var data = $.parseJSON(data);
            if(data.status == 1){
                if(data.is_pay == 1){
                    window.location.href = "http://wx.yunxiaofu.com.cn/index.php/Mobile/User/order_detail/order_id/"+data.result;
                }else{
                    window.location.href = "http://wx.yunxiaofu.com.cn/index.php/Mobile/Payment/getCode/pay_code/"+data.pay_code+"/order_id/"+data.result;
                }

            }else{
                layer.closeAll();
                myalert(data.msg);
            }
        });
    }
    function myalert(con){
        layer.alert(con,{title:false,closeBtn: 0,btn:false,time:1500});
    }
    function myconfirm(con,btn,fun){
        layer.open({
            content:con,
            title:false,
            closeBtn:false,
            btnAlign:'c',
            btn:btn,
            yes:function(index){
                fun();
                layer.close(index);
            }
        });
    }
    function address(){
        var action ="{:U('user/user/addr')}";
        $('#add-form').attr('action',action);
        $('#add-form').submit();
    }
    function ticket_click(){
        var action ="/index.php/Mobile/Order/myticket.html";
        $('#add-form').attr('action',action);
        $('#add-form').submit();
    }

//    function test(obj) {
//        switch ($("input[name=shipping_type]:checked").attr("id")) {
//            case "radio01":
//                $("#Div1").show();
//                $("#Div2").hide();
//                break;
//            case "radio02":
//                $("#Div2").hide();
//                $("#Div1").hide();
//                break;
//            case "radio03":
//                $("#Div1").hide();
//                $("#Div2").show();
//                break;
//            default:
//                break;
//        }
//    }
</script>
</body>
</html>